{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <blockquote class="layui-elem-quote">
        <a href="{:url('articleAdd')}" class="layui-btn layui-btn-sm">添加文章</a>
    </blockquote>
    <table class="layui-table">
        <thead>
        <tr>
            <th>编号</th>
            <th>文章名称<span id="cateNameMsg">(点击查看内容)</span></th>
            <th>所属栏目</th>
            <th>排序</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="con">
        {volist name="list" id="vo"}
        <tr>
            <td class='visible-lg visible-md'>{$vo.id}</td>
            <td class='text-left'><a href='' class='green' title=''>{$vo.title} </a>&nbsp;</td>
            <td class='text-left'>{$vo.category_id}</td>
            <td><input type='text' size='10' data-id='{$vo.id}' value='{$vo.sort}' class='layui-input list_order'></td>
            <td>
                <a class="green" href="{:url('admin/article/articleEdit',['id'=>$vo.id])}" title="修改"><i class="icon icon-pencil2"></i></a> |
                <a class="red" href="javascript:del('{$vo.id}')" title="删除"><i class="icon icon-bin"></i></a> </td>
        </tr>
        {/volist}
        </tbody>
        <tfoot>
    </table>
</div>
{include file="common/foot"/}
<script src="/public/static/common/js/jquery.2.1.1.min.js"></script>
<script>
    layui.use('table', function(){
        var $= layui.jquery;
        $('body').on('blur','.list_order',function() {
            var id = $(this).attr('data-id');
            var sort = $(this).val();
            var loading = layer.load(1, {shade: [0.1, '#fff']});
            $.post('{:url("articleOrder")}',{id:id,sort:sort},function(res){
                layer.close(loading);
                if(res.code === 1){
                    layer.msg(res.msg, {time: 1000, icon: 1}, function () {
                        location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            })
        });
    });
    function del(id) {
        layer.confirm('你确定要删除该栏目及其子栏目吗？', {icon: 3}, function (index) {
            $.post('{:url("articleDel")}', {id: id}, function (data) {
                if (data.status === 1) {
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg(data.info,{icon:5});
                }
            });
            layer.close(index);
        });
    }
</script>
</body>
</html>